﻿using MediatR;
using Traceability.Commont.Domains.AnimalsDomainFiles;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;
namespace U.Enterprise.Api.Applications.Scalesetting
{
    public class WaitingCircleCteateHandler : IRequestHandler<WaitingCircleCteateCommond, Resqults>
    {


        private readonly IBateRepository<SlaughterCircle> _SlaughterCirle;

        public WaitingCircleCteateHandler(IBateRepository<SlaughterCircle> slaughterCirle)
        {
            _SlaughterCirle = slaughterCirle;
        }

        public async Task<Resqults> Handle(WaitingCircleCteateCommond request, CancellationToken cancellationToken)
        {

            var list = new Resqults() { Code = 0 };




            var res = new SlaughterCircle()
            {
                SlaughterCircledId=request.SlaughterCircledId,
                SlaughterCircledType=request.SlaughterCircledType,
                SlaughterCircleName=request.SlaughterCircleName,
                Departmentid=request.Departmentid,
                Head=request.Head.ToString(),
                Remark=request.SlaughterCircleName

            };

            var result=await _SlaughterCirle.Add(res);


            if(result>0)
            {
                list.Code = 1;
            }

            return list;


        }
    }
}
